import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';

/**
 * Base completion response DTO
 * Contains common properties for all completion responses
 */
export class BaseCompletionResponseDto {
  /**
   * The model used for generation
   */
  @ApiProperty({
    description: '使用的AI模型',
    example: 'claude-3-7-sonnet-20250219',
  })
  model: string;

  /**
   * The raw response from the AI provider
   */
  @ApiPropertyOptional({
    description: '原始AI服务提供商返回的数据',
    type: 'object',
  })
  rawResponse?: any;

  /**
   * Number of tokens used in the request
   */
  @ApiPropertyOptional({
    description: '请求使用的token数量',
    example: 150,
  })
  promptTokens?: number;

  /**
   * Number of tokens generated in the response
   */
  @ApiPropertyOptional({
    description: '响应生成的token数量',
    example: 50,
  })
  completionTokens?: number;

  /**
   * Total number of tokens used (prompt + completion)
   */
  @ApiPropertyOptional({
    description: '总共使用的token数量',
    example: 200,
  })
  totalTokens?: number;
}

/**
 * Text completion response DTO
 */
export class TextCompletionResponseDto extends BaseCompletionResponseDto {
  /**
   * The generated text
   */
  @ApiProperty({
    description: '生成的文本内容',
    example: '根据您的需求，我推荐以下解决方案...',
  })
  text: string;
}

/**
 * Chat completion response DTO
 */
export class ChatCompletionResponseDto extends BaseCompletionResponseDto {
  /**
   * The generated message
   */
  @ApiProperty({
    description: '生成的消息',
    type: 'object',
    properties: {
      role: {
        type: 'string',
        example: 'assistant',
        description: '消息发送者角色',
      },
      content: {
        type: 'string',
        example: '您好！有什么我可以帮助您的吗？',
        description: '消息内容',
      },
    },
  })
  message: {
    /**
     * Role of the message sender (typically 'assistant')
     */
    role: string;

    /**
     * Content of the message
     */
    content: string;
  };
}
